 
import { EActionCode } from "framework/FSM/Action/ActionCode";
import { ActionBase, ActionBaseOfCreep } from "../ActionBase";

/**
 * 预定Action
 */
export class ActionAttackController  extends ActionBaseOfCreep<IActionCMD<"attackController">>
{
     
    protected _execute(action: IActionCMD<"attackController">): EActionCode 
    {
        if(action.arg.entity.pos.distance(action.arg.controller.pos)>1)
        {
            action.arg.entity.mymoveTo({pos:action.arg.controller.pos,range:1},{});
            return EActionCode.RUNNING;
        }
        if(!action.arg.controller.reservation)
        {
            return  EActionCode.OK;
        }
        if( action.arg.controller.my)
        {
            return  EActionCode.OK;
        }
        if( action.arg.controller.room.isMyResverse())
        {
            return  EActionCode.OK;
        }
        action.arg.entity.attackController(action.arg.controller);
        return  EActionCode.RUNNING;
    }
}